package groups

import (
	"github.com/gin-gonic/gin"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/app/ginsrv/oplog"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core"
)

// Init 初始化
func Init(route *gin.RouterGroup, d core.CmsDomain) {
	group := createGroupsCtrl(d)
	cr := route.Group("groups")
	cr.GET("", oplog.OplogRoute("cms/groups/list", "获取信息组列表", group.getGroupPageList))
	cr.POST("", oplog.OplogRoute("cms/groups/add", "新增信息组", group.add))
	cr.GET(":groupid", oplog.OplogRoute("cms/groups/getone", "获取指定信息组的信息", group.getGroup))
	cr.DELETE(":groupid", oplog.OplogRoute("cms/groups/delete", "删除信息组", group.delete))
	cr.PUT(":groupid/desc", oplog.OplogRoute("cms/groups/update/desc", "修改信息组基本信息", group.updateDesc))
	cr.GET(":groupid/desc", oplog.OplogRoute("cms/groups/desc", "获取信息组的描述信息", group.getGroupDesc))
	cr.PUT(":groupid/ctrl", oplog.OplogRoute("cms/groups/update/ctrl", "修改信息组控制参数", group.updateCtrl))
	cr.GET(":groupid/ctrl", oplog.OplogRoute("cms/groups/ctrl", "获取信息组的控制参数信息", group.getGroupCtrl))
	cr.DELETE(":groupid/destroy", oplog.OplogRoute("cms/groups/destroy", "彻底删除信息组", group.destroy))
	cr.PUT(":groupid/recover", oplog.OplogRoute("cms/groups/recover", "恢复信息组", group.recover))
	cr.PUT(":groupid/stopcollecting", oplog.OplogRoute("cms/groups/update/stopcollecting", "停止信息组收集信息", group.stopCollecting))
	cr.PUT(":groupid/startcollecting", oplog.OplogRoute("cms/groups/update/startcollecting", "开始信息组收集信息", group.starCollecting))
	gir := route.Group("groupinfos")
	gir.GET(":groupid/infos", oplog.OplogRoute("cms/groupinfos", "分页获取指定信息组收集的信息列表", group.getGroupInfoPageList))
	gir.GET(":groupid/exists/:ids", oplog.OplogRoute("cms/groupinfos", "获取指定ｉｄ是否在指定组内", group.getGroupExistsInfos))
	gir.PUT(":groupid/infos/:infoids", oplog.OplogRoute("cms/groupinfos/app", "手动向组内添加信息", group.appendGIInfos))
	gir.DELETE(":groupid/infos/:infoids", oplog.OplogRoute("cms/groupinfos/delete", "删除组内信息", group.deleteGIInfos))
	gir.PUT(":groupid/weight/:giid", oplog.OplogRoute("cms/groupinfos/chgweight", "修改组内信息的权重", group.chgGIWeight))
	gir.DELETE(":groupid/infos", oplog.OplogRoute("cms/groupinfos/empty", "清空组内信息", group.emptyGIInfo))
	gir.PUT(":groupid/infos", oplog.OplogRoute("cms/groupinfos/refresh", "组内刷新", group.refreshGIInfo))
}
